<!--
 * @Author: lixb
 * @Date: 2020-08-19 10:29:30
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2020-09-22 15:42:10
 * @Descripttion: 精选福利礼包
-->
<template>
  <div>
    <el-card v-if="giftList.length > 0" class="box-card">
      <div slot="header" class="clearfix">
        <span class="modul-title">
          <img
            src="@/assets/img/精选福利礼包.png"
            style="height: 25px;width: 25px;margin-right: 10px;"
          />
          <span>精选福利礼包</span>
        </span>
      </div>
      <div class="text item gift-main">
        <div
          v-for="item in giftList"
          :key="item.id"
          class="gift-item"
          @click="openNewPage(item.address)"
        >
          <img :src="item.adCode" />
        </div>
        <div style="clear: both;"></div>
      </div>
    </el-card>
  </div>
</template>

<script>
  import { queryMarketAdPage } from '@/api/giftBag';
  export default {
    data() {
      return {
        giftList: [],
      };
    },
    activated() {
      this.getInfo();
    },
    methods: {
      getInfo() {
        let params = {
          adBannerNo: 1002,
          size: 4,
          current: 1,
          state: 1,
        };
        queryMarketAdPage(params).then(res => {
          if (res.status == 200) {
            this.giftList = res.data.records;
          }
        });
      },
      openNewPage(url) {
        this.$router.push({ path: '/jxGift/index', query: { url: url } });
      },
    },
  };
</script>

<style lang="scss" scoped>
  .el-card.is-always-shadow {
    border-radius: 10px;
  }
  .modul-title * {
    font-weight: bold;
    font-size: 18px;
    display: inline-block;
    vertical-align: middle;
  }
  .box-card {
    margin-top: 10px;
    .gift-item {
      img {
        width: 100%;
        height: 100%;
      }
      width: 50%;
      padding: 5px;
      height: 200px;
      cursor: pointer;
      float: left;
    }
  }
</style>
